#pragma once

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QList>
#include <QComboBox>
#include <QPushButton>
#include <QCheckBox>
#include <QLabel>
#include <QGroupBox>
#include <QDoubleSpinBox>
#include <QListWidget>
#include <QListWidgetItem>

#include "src/QMuscleWindow/QNode.h"
#include "src/QMuscleWindow/QAbstractMuscle.h"
#include "src/QNeuronWindow/QNerveTissue.h"

class QPropertyWidget: public QWidget
{
    Q_OBJECT
private:
    int type;
    int item;
    int exItem;

    QWidget *freeWidget;
    QVBoxLayout *freeLayout;
    QList <QWidget*> freeWidgetList;

    QWidget *nodeWidget;
    QVBoxLayout *nodeLayout;
    QVBoxLayout *nodePropertyLayout;
    QList <QWidget*> nodeWidgetList;
    QList<QComboBox*> connectionComboBoxList;
    QComboBox *nodeComboBox;
    QPushButton *connectionAddButton;
    QPushButton *connectionRemoveButton;
    QPushButton *networkEditButton;
    QPushButton *nodeRemoveButton;

    QWidget *muscleWidget;
    QVBoxLayout *muscleLayout;
    QVBoxLayout *musclePropertyLayout;
    QList <QWidget*> muscleWidgetList;
    QComboBox *muscleComboBox;
    QPushButton *muscleRemoveButton;

    QWidget *nerveWidget;
    QVBoxLayout *nerveLayout;
    QVBoxLayout *nervePropertyLayout;
    QList <QWidget*> nerveWidgetList;
    QComboBox *nerveComboBox;
    QPushButton *nerveRemoveButton;
    QList <QCheckBox*> nerveCheckBoxList;

    QTabWidget *tabWidget;

    QVBoxLayout *mainLayout;

protected:
    void createFreeWidget(void);
    void createNodeWidget(void);
    void createMuscleWidget(void);
    void createNerveWidget(void);

public:
    QPropertyWidget(QWidget* parent = 0);

    void addItem(QNode *node);
    void addItem(QAbstractMuscle *muscle);
    void addItem(QNerveTissue* nerveTissue);

public slots:
    void setGridStep(int _gridStep);
    void setBinding(bool _hasBinding);

    void selectConnection(int connection);

    void addConnection(void);
    void addConnection(int sender, int channel, int receiver);

    void removeConnection(void);
    void removeConnection(int sender, int channel, int receiver);

    void editNetwork(void);

    void removeNode(void);
    void removeNode(int node);

    void removeMuscle(void);
    void removeMuscle(int muscle);

    void removeNerve(void);
    void removeNerve(int nerve);

    void selectNode(int _node);
    void selectMuscle(int _muscle);
    void selectNerve(int _nerve);

    void setType(int _type);

    void toggleCurve(bool _show);

signals:
    void gridStepChanged(int);
    void bindingChanged(bool);

    void addConnectionSignal(int);
    void removeConnectionSignal(int sender, int channel, int receiver);
    void editNetworkSignal(int);

    void removeNodeSignal(int);
    void removeMuscleSignal(int);
    void removeNerveSignal(int);

    void nodeSelected(int);
    void muscleSelected(int);
    void nerveSelected(int);

    void addNerveCurve(int);
    void removeNerveCurve(int);
};
